<template>
    <div  class="body">
     <div id="loginDiv">
        <form id="form">
            <h1>注册</h1>
         
             <span>账号:</span><input type="text"  placeholder="请输入注册账号" v-model="rual.userUsername">
           <br><br>
             <span>密码:</span><input type="password" placeholder="请设置密码" v-model="rual.userPassword">
      
            <div style="text-align: center;margin-top: 30px;">
                <button type="button" class="button" @click="SubmitRegister">注册</button>
                <router-link to="/"><button class="button">返回</button></router-link>
            </div>
        </form>
    </div>
    </div>
</template>

<script>
export default {
    name:"Register",
    data(){
        return{
            rual:{
             userUsername:'',
             userPassword:''
            }
         
        }
    },
    methods:{
    SubmitRegister(){
        this.$axios.post('http://localhost:8888/api/register',this.rual).then(res=>{
           
                if(res.data.state=true){
                     this.$notify({
                     message: '恭喜您，注册成功',
                 });
                    this.$router.push({path: "/"})
                }
                else if(res.data.state=false){
                    this.$notify({
                     message: '很遗憾，注测失败',
                 });
                }
             
        })
    }
    }
    
}
</script>

<style scoped>
*{
            margin: 0;
            padding: 0;
        }
         
        .body {
            display: flex;
            align-items: center;
            /* align-content: center; */
            justify-content: center;
            height: 100vh;
            flex-wrap: wrap;
            background-image: url(../assets/4.jpg);
            background-size: cover;
        }
         
        #loginDiv {
            width: 37%;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 300px;
            background-color: rgba(75, 81, 95, 0.3);
            /* background-color: white;
            opacity: 45%; */
            box-shadow: 7px 7px 17px rgba(200, 54, 54, 0.5);
            border-radius: 5px;
        }
           #loginDiv h1{
             position: relative;
             bottom: 2rem;
             left: 5rem;
    
             color: aliceblue;
         }
        #name_trip {
            margin-left: 50px;
            color: red;
        }
         
        p {
            position: relative;
            top: 25px;
           left: -15%;
           
            color: azure;
        }
         
        input {
            margin-left: 15px;
            border-radius: 5px;
            border-style: hidden;
            height: 31px;
            width: 150px;
           background-color: rgba(216, 191, 216, 0.5);
            outline: none;
            color: #f0edf3;
            padding-left: 10px;
        }
         
        .button {
            border-color: cornsilk;
            background-color: rgba(100, 149, 237, .7);
            color: aliceblue;
            border-style: hidden;
            border-radius: 5px;
            width: 100px;
            height: 31px;
            font-size: 16px;
           margin-left: 1rem;
        } 
</style>